﻿using System;
using System.Windows;

namespace FreeGoo.WpfRenderer
{
    public static class CrossMouse
    {
        private static Func<UIElement, Point> _getPosition;

        public static bool IsLeftButtonDown { get; set; }

        public static Point GetPosition(UIElement relativeTo)
        {
            if (_getPosition == null)
            {
                return new Point(0, 0);
            }

            return _getPosition(relativeTo);
        }

        public static void MouseMoved(Func<UIElement, Point> getPosition)
        {
            _getPosition = getPosition;
        }

        public static void MouseLeftButtonDown(Func<UIElement, Point> getPosition)
        {
            IsLeftButtonDown = true;
            _getPosition = getPosition;
        }

        public static void MouseLeftButtonUp(Func<UIElement, Point> getPosition)
        {
            IsLeftButtonDown = false;
            _getPosition = getPosition;
        }
    }
}